<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>集中提回业务处理系统</title>
<link href="../../css/general1.css" rel="stylesheet" type="text/css" />
<link href="style/css.css" rel="stylesheet" type="text/css" />
<link href="../../zephyr/css/drift.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../script/prototype.js"></script>
<script type="text/javascript" src="../../zephyr/js/CookieOperator.js"></script>
</head>
<body>
<center>
	<div id="dtable"></div>
	<table width="93%" border="0" class="title">
	  <tr>
	    <td class="font3" colspan="5" bgcolor="#CED1DD">
	    	<input name="" type="button" value="提交" onclick="submin();" class="btn1"/>
			<input name="" type="button" value="返回" onclick="window.location='batscan.html';" class="btn1"/>
		</td>
	  </tr>
	</table>
</center>

<!-- This is the lightbox content -->
<div id="light" class="white_content">
	<p align="right"><a href = "javascript:void(0)" onclick = "closewin()">
	Close
	</a></p>
	<table width="869" border="0" >
	  <tr>
	    <td width="856" align="left"><img id="ticket" src="pic/s.gif" width="866" height="405"  style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);"/></td>
	  </tr>
	  <tr>
	    <td align="left">&nbsp;</td>
	    </tr>
	</table>
	<table>
	<tr>
	<td>
	  <label>
	  <input type="submit" name="Submit" value="上一张" onclick="back()"/>
	  </label>
	   <label></label>
	   <label>
	  <input type="submit" name="Submit2" value="下一张" onclick="next()"/>
	  </label>
	    <label>
	  <input type="submit" name="Submit2" value="删　除" onclick="delFile()" />
	  </label> 
	</td>
	</tr>
	</table>
</div>
<div id="fade" class="black_overlay"></div>
<object id="uploadOcx" name="uploadOcx" on
		classid="clsid:4E1C94DD-78DE-4DCB-B0B6-3745C728EFA8"
		width=0
		height=0
		align=middle
		hspace=0
		vspace=0 viewastext>
</object>

<script type="text/javascript">
	var imgArray = new Array();//图像数组
	/**
	 * 获取指定路径图片,显示在table中
	 * @param {Object} path 图片路径
	 */
	function loadImgs(path) {
		var dtable = "<table width='99%' border='0' class='title'><tr>";
		var imastart="0";
		var images = [];
		var imgRows = "";
		var img;
		try {
			fso = new ActiveXObject("Scripting.FileSystemObject"); 
		}catch (e) {
			alert(e.message);
			return;
		}
		fldr = fso.GetFolder(path); 
		fc = new Enumerator(fldr.files); 
		var i = 0;
		for (;!fc.atEnd();fc.moveNext()) { 
			i++;
			s = fc.item(); //取文件对象
			f = fso.GetFile(s);
			var obj = new Object();
			obj.path = f;
			obj.name = f.name;
			if (f.type == "JPEG 图像" || f.type == "BMP 文件") {
				imgArray.push(obj);
				images[i - 1] = obj;
				
				imgRows += "<td width='278' ><a href=javascript:openwin($('" + f.name + "'));><img id='" + f.name + "' src='pic/s.gif' " +
				"style='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);width:200;height:90;' /></a></td>";
				if (i % 5 == 0) {
					imgRows += "</tr><tr>";
				}
			}
			
		}
		var dhead = "<td class='font3' colspan='5' bgcolor='#CED1DD'><div align='left'>图像列表　　　　　　　　　　　　　	　　　　　　　	　　　　　　　	共扫描图像<font color='red'><B>　" +
			+imgArray.length+ "　</B></font>张 　　　　　　此网点人行数据共<font color='red'><B>　" +imgArray.length+ "　</B></font>张</div></td></tr>";
		dtable += dhead + imgRows + "</tr></table>";
		$("dtable").innerHTML = dtable;
		$A(images).each(function(el) {
			$(el.name).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = el.path;
		});
	}
	
	var exchno = getCookie("scan_exchno");
	var scanPathCook = getCookie("scanPath");
	if(scanPathCook != '') {
		var loadPath = unescape(scanPathCook) + exchno;
		//alert(loadPath);
		loadImgs(loadPath);
	}else {
		alert('未扫描图像,请扫描后查看。')
	}
	
	
	/**
	 * 打开窗口显示指定名称的图片
	 * @param {Object} el 指定img标签元素
	 */
	function openwin(el) {
		var img = el.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src;
		document.getElementById('ticket').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = img;
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
		
	}
	
	/**
	 * 关闭窗口
	 */
	function closewin() {
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none';
	}
	
  	function submin() {
		if (confirm("确认扫描上传图像？是－选择确定，否-选择取消")){
			var exchno = getCookie("scan_exchno");
			alert(exchno);
			var scanTestPath = "d:\\1001\\";
			var commandid = "1102";
		  	var xmldata = "<zms><scan path='"+exchno+"' dpi='300' imgcount='' imgname=''></scan></zms>";
			alert(xmldata);
		  	var DOcxtest1 = $("uploadOcx");
			var a = '';
			var varRet = null;
			if(xmldata) {
		  		varRet = DOcxtest1.Zms(commandid,xmldata);
		  	}
			if(varRet) {//控件返回有值，将cookie设置exchno
				alert("操作成功: " + varRet);
				deleteCookie("scan_exchno");
				window.location.href="batscan.html";
			}
		}
	}
	
	/**
	 * 删除文件
	 */
	function delFile() {
		if (!confirm("确认删除？是－选择确定，否-选择取消")) {
			return;
		}
		var img = document.getElementById('ticket').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src;
		try {
			fso = new ActiveXObject("Scripting.FileSystemObject"); 
		}catch (e) {
			alert(e.message);
			return;
		}
		f = fso.GetFile(img);
		f.Delete();
		loadImgs("D:/"+exchno);
		closewin();
	}
	/**
	 * 下一条
	 */
	function next() {
		var imgPath = document.getElementById('ticket').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src;
		$A(imgArray).each(function(el) {
			if (el.path == imgPath) {
				var nIndex = imgArray.indexOf(el) + 1;
				if (nIndex == imgArray.length) nIndex = 0;
				var nextImg = imgArray[nIndex].name;
				openwin($(nextImg));
			}
		})
	}
	/**
	 * 上一条
	 */
	function back() {
		var imgPath = document.getElementById('ticket').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src;
		$A(imgArray).each(function(el) {
			if (el.path == imgPath) {
				var pIndex = imgArray.indexOf(el) - 1;
				if (pIndex < 0) pIndex = imgArray.length-1;
				var prevImg = imgArray[pIndex].name;
				openwin($(prevImg));
			}
		})
	}
</script>
</body>
</html>
